<div class="container">

    <div class="page-header">
        <div class="row">
            <h1 class="span8"><? if($post_action=='EDIT'){ echo 'Edit';}else echo 'Add';?> <?=ucfirst($post_type)?></h1>
            <span class="span4">

            </span>
        </div>


    </div>

    <div class="row">

        <div class="span8">

            <form class="form-horizontal" name="general_form" id="general_form" method="post" action="<?=base_url("objects/submit_general_form")?>">

                <?php
                    $this->load->view('parts/object_navigation');
                ?>

                <input type="hidden" name="post_action" id="post_action" value="<?=$post_action;?>" />
                <? if($post_action=='EDIT'){?><input type="hidden" value="<?=$object['object_ID'];?>" name="object_ID" id="object_ID"><?}?>

                <fieldset>  

                    <div class="group">

                        <span class="group-title"> GENERAL &nbsp;&nbsp;

                            <a href="javascript:" title="Add attribute" class="view_add_attributes_on_group" data-holder="<? if($post_action=='EDIT')echo $general_group_ID;?>"><i class="icon-plus"></i> Add attribute</a>
                            <a href="javascript:" title="Edit attribute" class="view_attributes_on_group" data-holder="<? if($post_action=='EDIT')echo $general_group_ID;?>"><i class="icon-wrench"></i> Edit attribute</a>

                        </span>          

                        <div class="control-group">
                            <label class="control-label">Select type:</label>
                            <div class="controls docs-input-sizes">

                                <select class="span3" name="object_type_ID" id="object_type_ID" <? if($post_action=='EDIT') echo 'disabled="disabled"'?>>
                                    <option value="0">--Please Select</option>

                                    <?foreach($object_types as $type):?>
                                        <?
                                            $sel = '';
                                            if(isset($object) && $object['object_type_ID']==$type['ID'])$sel='selected="selected"';
                                        ?>
                                        <option value="<?=$type['ID']?>" <?=$sel?>><?=ucfirst($type['type'])?></option>

                                        <? endforeach; ?>


                                </select>
                                <? if($post_action=='EDIT'){?><input type="hidden" value="<?=$object['object_type_ID'];?>" name="object_type_ID"><?}?>

                            </div>

                        </div>

                        <div class="control-group">
                            <label class="control-label">Select destination:</label>
                            <div class="controls docs-input-sizes">

                                <select class="span3" name="object_destination" id="object_destination">
                                    <option value="0">--Please Select</option>
                                    <? foreach($destinations as $destination): ?>

                                        <?
                                            $sel = '';
                                            if(isset($object) && $object['destination_ID']==$destination['ID'])$sel='selected="selected"';
                                        ?>

                                        <option value="<?=$destination['ID']?>" <?=$sel?>><?=$destination['name'];?></option>

                                        <?
                                            $children = $this->destinations_model->get_children($destination['ID']);
                                            foreach ($children as $child) : ?>

                                            <?
                                                $sel = '';
                                                if($object['destination_ID']==$child['ID'])$sel='selected="selected"';
                                            ?>

                                            <option value="<?=$child['ID']?>" <?=$sel?>>-- <?=$child['name'];?></option>


                                            <? endforeach; ?>
                                        <? endforeach; ?>

                                </select>

                                <!--<a class="btn btn-mini" title="New Destination"><i class="icon-plus"></i></a>-->

                            </div>
                        </div>

                        <div class="data-container"> <? if($post_action=='EDIT')echo $general_html;?> </div>       

                    </div>

                </fieldset>
                
                <div class="status_info"></div> 

                <div class="form-actions">
                    <div class="row">
                        <span class="span2 save">
                            <button type="submit" class="btn btn-primary" disabled="disabled" id="submit_general">Save changes</button>
                        </span>
                    </div>

                </div>

            </form>
            <script type="text/javascript">

                var post_action = '<?=$post_action?>';
                <? if($post_action=='EDIT'){?>
                    var object_ID = '<?=$object['object_ID'];?>';
                    <?}?>

            </script>

        </div>

    </div>

</div>